1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| from turtle import *
def branch(length:float=160.0, angle:float=30.0, w:float=16.0, r:int=0, g:int=0, b:int=0) -> None: w *= 0.8 width(w) r += 10 g += 20 b += 30 pencolor(r % 200, g % 200, b % 200)
length *= 0.8 lt(angle) fd(length)
if length > 10.0: branch(length, angle, w, r, g, b) width(w) pencolor(r % 200, g % 200, b % 200) bk(length) rt(angle * 2.0) fd(length) if length > 10.0: branch(length, angle, w, r, g, b) width(w) pencolor(r % 200, g % 200, b % 200) bk(length) lt(angle)
def main() -> None: speed(0) setup(1200, 800) width(16) colormode(255) pencolor(0, 0, 0) lt(90) pu() bk(340) pd() fd(180) branch() done()
if __name__ == '__main__': main()
|